import Lexical.Lex;
import Lexical.Token;
import Syntax.Item;
import Syntax.Symbol;
import Syntax.Syn;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class Lex_syn {
    private static final String fileAdd ="src\\词法规则.txt";
    private static final String codeSource ="src\\code.txt";
    private static final String tokenFile = "src\\token.txt";
    private static final String syntaxFile = "src\\syn.txt";
    public static void main(String[] args){
        //词法分析
        ArrayList<Token> tokenList;
        Lex lexAnalysis = new Lex(fileAdd);
        lexAnalysis.NFA_to_DFA();
        tokenList = lexAnalysis.scanCode(codeSource,tokenFile);
        lexAnalysis.showTokenList(tokenList);
        Token end = new Token();
        end.setOrigin("#");
        end.setClassification("delimiter");
        tokenList.add(end);
        //语法分析
        Syn synAnalysis = new Syn( syntaxFile );
        synAnalysis.showProds();
        synAnalysis.collection_ItemSet();
        //synAnalysis.showAnalysisTables();
        synAnalysis.parsing(tokenList);


    }
}
